import Vue from 'vue'
import App from './App.vue'
import 'normalize.css'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import shell from 'vue-shell'
import JwChat from 'jwchat'
import MyTree from '@/components/tree/index.js'
import vueFilePreview from 'gxd-file-preview';

import axios from 'axios'
const http = axios.create({
  baseURL: 'https://jsonplaceholder.typicode.com'
})
Vue.prototype.$request = http

Vue.use(ElementUI)
Vue.use(shell)
/* 在 0.2.041 之前的版本需要引入 css */
// import 'jwchat/lib/JwChat.css';
Vue.use(JwChat)
Vue.component('my-tree', MyTree)
//初始化自定义插件，（pdf.js,worker.js文件建议放在本地服务器),cdn有可能不稳定
Vue.use(vueFilePreview,{
  pdf: 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.0.288/build/pdf.min.js', //pdf插件
  worker:'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.0.288/build/pdf.worker.min.js',//pdf.work插件
});



Vue.config.productionTip = false

// 建立连接
// store.commit('websock_init', 'ws://192.168.110.100:8010')

setInterval(() => {
  localStorage.setItem('娃哈哈', Math.random())
})

// 监听localStorage变化
// window.addEventListener('storage', () => {
//   console.log('localStorage发生改变了')
// })


// 创建共享线程
var worker = new SharedWorker('sharedworker.js')
// 启动线程端口
worker.port.start()
// 线程监听消息
worker.port.addEventListener('message', event => {
  console.log('接收到的数据', event.data)
})
worker.port.postMessage('1243')
Vue.prototype.$sharedworker = worker


new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')
